package com.vben.system.api.feign;

import com.vben.common.core.constant.ServiceNameConstant;
import com.vben.common.core.util.R;
import com.vben.common.feign.interceptor.FeignInterceptor;
import com.vben.system.api.entity.SysUser;
import com.vben.system.api.feign.fallback.RemoteUserFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户远程服务
 *
 * @author sunnfun
 */
@FeignClient(contextId = "remoteUserService",
        value = ServiceNameConstant.SYSTEM_SERVICE,
        configuration = FeignInterceptor.class,
        fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService {

    /**
     * 根据用户名查询用户
     */
    @GetMapping("/user/username")
    R<SysUser> getUserByUsername(@RequestParam("username") String username);

    @GetMapping("/user/phone")
    R<SysUser> getUserByPhone(@RequestParam("phone") String phone);

    /**
     * 根据用户id获取用户权限列表
     */
    @GetMapping("/user/permission")
    R<List<String>> getUserPermissionList(@RequestParam("userId") Long userId);

    /**
     * 根据用户id获取用户角色列表
     */
    @GetMapping("/user/role")
    R<List<String>> getUserRoleList(@RequestParam("userId") Long userId);

    /**
     * 新增用户
     */
    @PostMapping("/user")
    R<Long> addUser(@RequestBody SysUser sysUser);

    /**
     * 更新用户
     */
    @PutMapping("/user/login")
    R<Boolean> updateUser(@RequestBody SysUser sysUser);

}
